home *** CD-ROM | disk | FTP | other *** search
- /*//////////////////////////////////////////////////////////////////////
- filename: conditions.js
- copyright(c): Tiny Software cortp 2002, 2003 (http://www.tinysoftware.com)
- author: Jozef Palocko (jpalocko@tinysoftware.com)
- product: Tiny Personal Firewall 5.x
- description: implemetation of Global conditions HTML code
- ///////////////////////////////////////////////////////////////////////*/
-
- //main function
-
-
- //return conditions string as HTMLcode
- function GetConditionsHtml(strFile)
- {
- var strConditions = "";
- var xmlDoc = LoadDOM (strFile);
- //get all checked conditions
- var CheckedConditions = window.external.GetConditions();
- // Query a node-set.
- var oNodes = xmlDoc.selectNodes('//Condition[@Type = "Global"]');
- for (i=0; i<oNodes.length; i++)
- {
- oNode = oNodes.nextNode;
- if (oNode != null)
- {
- sIdValue = oNode.getAttribute("id");
- cndName = Math.pow(2, parseInt( sIdValue));
- bChecked = cndName & CheckedConditions?1:0;
- strConditions += GetCheckBoxHtml(cndName, oNode.text, bChecked) + "<br>";
- }
- }
-
- return strConditions;
- }
- //condition checkbox handler
- function OnClickedCheckbox(CheckBox)
- {
- cndMask = parseInt(CheckBox.name);
- bState = CheckBox.checked? 1:0;
- //set state of checked condition
- window.external.SetConditions(cndMask, bState);
- }
-
- //return string with Checkbox tag HTML code
- function GetCheckBoxHtml(strName, strText, bSelected)
- {
- Val ="";
- if (bSelected)
- Val = "CHECKED";
- return '<input type="checkbox" '+ Val + ' name="' + strName + '" OnClick="OnClickedCheckbox(this)">' + strText ;
- }
-
- //load XML document
- function LoadDOM(strFile)
- {
- var dom;
- try
- {
- dom = new ActiveXObject("MSXML2.DOMDocument.4.0");
- dom.async = false;
- dom.validateOnParse = false;
- dom.resolveExternals = false;
- dom.load(strFile);
- }
- catch (e)
- {
- alert(e.description);
- }
- return dom;
- }
-